package P8.T02;

import java.io.*;

public class T02 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //writeFile(new Student("张三",20));
        readFile();
    }

    private static void readFile() throws IOException, ClassNotFoundException {
        FileInputStream fis=new FileInputStream("D:\\b1.dat");
        ObjectInputStream ois=new ObjectInputStream(fis);
        Student stu=(Student)ois.readObject();
        ois.close();
        System.out.println(stu.getName());
        System.out.println(stu.getAge());
    }

    private static void writeFile(Student stu) throws IOException {
        FileOutputStream fos=new FileOutputStream("D:\\b1.dat");
        ObjectOutputStream oos=new ObjectOutputStream(fos);
        oos.writeObject(stu);
        oos.close();
    }
}
